package com.kanesoft.android.gdx.actors.fight;

import com.kanesoft.android.gdx.widgets.sprites.SpriteInfo;

public class FighterPunching extends FightActorStateMachine{
    
    FightActorObject fightActor;
    
    public FighterPunching(SpriteInfo stateSpriteInfo, FightActorObject actor) {
        super(stateSpriteInfo, actor);
        fightActor = actor;
    }

    @Override
    public boolean OnEnter() {
        
        if (fightActor.getActorState() != null) {
            if (fightActor.getActorState().equals(fightActor.fallingKickState)) return false;
            if (fightActor.getActorState().equals(fightActor.fallingPunchState)) return false;
        }
        
        actorSprite.setAnimationInLoop(false);
        actorSprite.setSpriteInfo(stateSpriteInfo);
        
        return true;
    }

    @Override
    public boolean OnUpdate() {

        if (actor.getWorldControl().isObjectOnTheGround(actor) == false) {
            actor.setActorState(fightActor.fallingPunchState);
            return false;
        }
        
        return fightActor.waitingState.OnUpdate();
    }

    @Override
    public String getStateName() {
        return "Punching";
    }
    
    

}
